using Mono.Boost.Graph;
using System.Collections.Generic;
using NUnit.Framework;
using System;

[TestFixture]
public class TestBfs
{
    public void run_generic(uint verticesCount, Pair<uint,uint>[] edges, uint[] good)
    {
        StaticGraph g = new StaticGraph(verticesCount, edges);
        StaticPropertyMap<uint> layer = new StaticPropertyMap<uint>(g.highestVertexId+1);

        Bfs.calculate_layers(g,layer,0);

        foreach(uint v in g.vertices)
        {
            if(layer.ContainsKey(v))
                Assert.AreEqual(good[v],layer[v],"Vertex in wrong layer");
            else
                Assert.AreEqual(good[v],~0U,"Not reached reachable vertex");
        }
    }
    [Test]
    public void test3()
    {
        Pair<uint,uint>[] tab = new Pair<uint,uint>[]
        {
            new Pair<uint,uint>(0,1),
            new Pair<uint,uint>(7,0),
            new Pair<uint,uint>(1,5),
            new Pair<uint,uint>(2,3),
            new Pair<uint,uint>(6,4),
            new Pair<uint,uint>(5,7),
            new Pair<uint,uint>(4,2),
            new Pair<uint,uint>(3,4),
            new Pair<uint,uint>(5,2)
        };
        uint[] good = new uint[]{0,1,3,4,5,2,~0U,3};
        run_generic(8,tab,good);
    }
}
